package com.gaogzhen.controller;

import com.gaogzhen.model.LoginForm;
import com.gaogzhen.model.LoginUser;
import com.gaogzhen.service.LoginService;
import com.gaogzhen.utils.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 * @version 1.0
 * @description 登录控制器
 * @date 2022-07-05 10:52
 */
@RestController
@Api(tags = "登录的控制器")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    @ApiOperation(value = "会员登录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "loginForm", value = "登录的表单参数")
    })
    public R<LoginUser> login(@RequestBody @Validated LoginForm loginForm) {
        return R.ok(loginService.login(loginForm));
    }
}
